package com.shhm.business.controller;

import com.shhm.business.service.ProductTypeService;
import com.shhm.common.annotations.OperateLog;
import com.shhm.common.dto.request.RequestList;
import com.shhm.common.dto.response.AjaxResultPlus;
import com.shhm.common.entity.common.ProductTypeEntity;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author JackZ
 * @version 1.0
 * @description: TODO
 * @date 2025/9/10 下午2:20
 */
@RestController
//@RequestMapping("/admin")
public class ProductTypeController {
    @Resource
    private ProductTypeService productTypeService;
    
    @GetMapping("/business/product/type")
    public AjaxResultPlus productTypePage(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(defaultValue = "1") Integer isPage
    ){
        return productTypeService.productTypeList(pageNum, pageSize, isPage);
    }

    @PostMapping("/admin/product/type/search")
    public AjaxResultPlus pageSearchList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestBody ProductTypeEntity entity
    ){
        return productTypeService.pageSearchList(pageNum,pageSize,entity);
    }

    @PostMapping("/admin/product/type")
    @OperateLog(module="商品类型管理",type = "POST",desc = "添加系统商品类型信息")
    public AjaxResultPlus add(@RequestBody ProductTypeEntity entity){
        return productTypeService.add(entity);
    }

    @PutMapping("/admin/product/type")
    @OperateLog(module="商品类型管理",type = "PUT",desc = "修改系统商品类型信息")
    public AjaxResultPlus update(@RequestBody ProductTypeEntity entity){
        return productTypeService.update(entity);
    }

    @DeleteMapping("/admin/product/type")
    @OperateLog(module="商品类型管理",type = "DELETE",desc = "删除系统商品类型")
    public AjaxResultPlus delete(@RequestBody RequestList ids){
        return productTypeService.delete(ids);
    }
}
